<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="项目名称" prop="parentId">
        <el-input
          v-model="queryParams.projectName"
          placeholder="请输入项目名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="项目令号" prop="projectCode">
        <el-input
          v-model="queryParams.projectCode"
          placeholder="请输入项目令号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="年限" prop="projectTime">
        <el-date-picker clearable size="small" style="width: 200px"
          v-model="queryParams.projectTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择年限">
        </el-date-picker>
      </el-form-item>
      <!-- <el-form-item label="项目类型" prop="projectType">
        <el-select v-model="queryParams.projectType" placeholder="请选择项目类型" clearable size="small">
          <el-option
            v-for="dict in projectTypeOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item> -->

      <el-form-item label="项目时限">
        <el-date-picker
          v-model="queryProjectDateRange"
          size="small"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>

      <el-form-item label="是否超时" prop="isTimeOut">
        <el-select v-model="queryParams.isTimeOut" placeholder="请选择是否超时" clearable size="small">
          <el-option
            v-for="dict in isTimeOutOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="里程碑" prop="isImportant">
        <el-select v-model="queryParams.isImportant" placeholder="请选择是否为里程碑节点" clearable size="small">
          <el-option
            v-for="dict in isImportantOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="责任部门" prop="deptName" class="item">
        <treeselect v-model="queryParams.deptId" clearable :options="deptOptions" :disable-branch-nodes="false" placeholder="请选择归属部门"  style="width:200px;" />
      </el-form-item>
      <el-form-item label="责任人" prop="userId">
          <treeselect v-model="queryParams.userId" :options="userTree" :disable-branch-nodes="true" :show-count="false" placeholder="请选择用户" style="width:200px;" />
      </el-form-item>
      <el-form-item label="工作状态" prop="state" class="item">
        <el-select v-model="queryParams.state" placeholder="请选择工作状态" clearable size="small">
          <el-option
            v-for="dict in stateOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['project:project:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['project:project:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['project:project:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['project:project:export']"
        >导出</el-button>
      </el-col>
	  <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="projectList" @selection-change="handleSelectionChange"  border style="width: 100%"
    height="600" :row-class-name="tableRowClassName">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="项目主键" align="center" prop="projectId" v-if="false"/>
      <el-table-column label="项目名称" align="center" :show-overflow-tooltip="true" width="440" fixed>
        <template slot-scope="scope">
          <router-link :to="'/project/tree/data/' + scope.row.projectId" class="link-type">
            <span>{{ scope.row.projectName }}</span>
          </router-link>
        </template>
      </el-table-column>
      <el-table-column label="项目令号" align="center" prop="projectCode" width="260"/>
      <el-table-column label="年限" align="center" prop="projectTime" width="80" />
      <el-table-column label="项目类型" align="center" prop="projectType" :formatter="projectTypeFormat" v-if="false" />
      <el-table-column label="开始时间" align="center" prop="startTime" width="100">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.startTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="结束时间" align="center" prop="finishTime" width="100">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.finishTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="实际完成时间" align="center" prop="relFinishTime" width="100">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.relFinishTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="超时" align="center" prop="isTimeOut" :formatter="isTimeOutFormat" width="60" />
      <el-table-column label="项目总师" align="center" prop="technologyLeader" width="80"/>
      <el-table-column label="项目经理" align="center" prop="nickName" width="80"/>
      <el-table-column label="状态" align="center" prop="state" :formatter="stateFormat" width="80"/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right"  width="240">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-tickets"
            @click="handleDetails(scope.row)"
            v-hasPermi="['project:project:details']"
          >详情</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-tickets"
            @click="handleTeam(scope.row)"
            v-hasPermi="['project:project:details']"
          >项目组</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['project:project:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['project:project:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改项目管理对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body :close-on-click-modal="false">
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
      <el-row>
        <el-col :span="12">
          <el-form-item label="项目名称" prop="projectName">
            <el-input v-model="form.projectName"  placeholder="请输入项目名称" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="项目令号" prop="projectCode">
            <el-input v-model="form.projectCode" placeholder="请输入项目令号" />
            <el-input v-model="form.projectType" placeholder="请输入项目令号" v-if="false"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="开始时间" prop="startTime">
            <el-date-picker clearable size="small" style="width:100%"
              v-model="form.startTime"
              type="date"
              value-format="yyyy-MM-dd"
              placeholder="选择开始时间">
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="结束时间" prop="finishTime">
            <el-date-picker clearable size="small" style="width:100%"
              v-model="form.finishTime"
              @change="checkTime"
              type="date"
              value-format="yyyy-MM-dd"
              placeholder="选择结束时间">
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="完成时间" prop="relFinishTime">
            <el-date-picker clearable size="small" style="width:100%"
              v-model="form.relFinishTime"
              type="date"
              value-format="yyyy-MM-dd"
              placeholder="选择实际完成时间">
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="项目总师" prop="technologyLeaderUserId">
              <treeselect v-model="form.technologyLeaderUserId" :options="userTree" :disable-branch-nodes="true" :show-count="false" placeholder="请选择用户" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="项目经理" prop="userId">
              <treeselect v-model="form.userId" :options="userTree" :disable-branch-nodes="true" :show-count="false" placeholder="请选择用户" />
          </el-form-item>
        </el-col>
        
      </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 项目组管理 -->
     <el-dialog :title="team.title" :visible.sync="team.open" :close-on-click-modal="false"  width="800px"  append-to-body>
        <el-tabs v-model="team.activeName">
          <el-tab-pane id="teamSave" label="添加人员" name="first">
            <el-form ref="team.form" :model="team.form" :rules="team.rules" label-width="80px" style="height:400px;">
              <el-form-item label="成员姓名" prop="userIds">
                <treeselect v-model="team.form.userIds" :options="userTree" :multiple="true"
                :disable-branch-nodes="true" :show-count="false" 
                placeholder="请选择用户" style="width:100%"/>
              </el-form-item>
              <el-form-item label="成员角色" prop="teamRole">
                <el-select v-model="team.form.teamRole" placeholder="请选择项目成员角色" clearable style="width:100%">
                      <el-option
                        v-for="dict in projectRoleOptions"
                        :key="dict.dictValue"
                        :label="dict.dictLabel"
                        :value="dict.dictValue"
                      />
                    </el-select>
              </el-form-item>
            </el-form>
              
          </el-tab-pane>
          <el-tab-pane label="成员列表" name="second">
              <el-row :gutter="10" class="mb8">
              </el-row>
              <el-form :model="team.queryParams" ref="team.queryForm" :inline="true" v-show="showSearch" label-width="68px">
                  <el-form-item label="成员姓名" prop="nickName">
                    <el-input
                      v-model="team.queryParams.nickName"
                      placeholder="请输入成员姓名"
                      clearable
                      size="small"
                      @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                  <el-form-item label="成员角色" prop="teamRole">
                    <el-select v-model="team.queryParams.teamRole" placeholder="请选择项目成员角色" clearable size="small">
                      <el-option
                        v-for="dict in projectRoleOptions"
                        :key="dict.dictValue"
                        :label="dict.dictLabel"
                        :value="dict.dictValue"
                      />
                    </el-select>
                  </el-form-item>
                  <el-form-item>
                    <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleTeamQuery">搜索</el-button>
                    <el-button icon="el-icon-refresh" size="mini" @click="resetTeamQuery">重置</el-button>
                  </el-form-item>
                </el-form>
              <el-table v-loading="loading" :data="team.teamList" border @selection-change="handleSelectionChange" style="width: 100%" height="400">
                    <el-table-column type="selection" width="55" align="center" />
                    <el-table-column label="成员名称" align="center" prop="nickName" />
                    <el-table-column label="人员角色" align="center" prop="teamRole" :formatter="isProjectRoleFormat" />
                    <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                      <template slot-scope="scope">
                        <el-button
                          size="mini"
                          type="text"
                          icon="el-icon-delete"
                          @click="handleTeamDelete(scope.row)"
                          v-hasPermi="['project:team:remove']"
                        >删除</el-button>
                      </template>
                    </el-table-column>
              </el-table>
              <pagination
                v-show="team.total>0"
                :total="team.total"
                :page.sync="team.queryParams.pageNum"
                :limit.sync="team.queryParams.pageSize"
                @pagination="getTeamList"
              />
          </el-tab-pane>
        </el-tabs>
        
      <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="submitTeamForm">保 存</el-button>
          <el-button @click="team.open = false">取 消</el-button>
        </div>
    </el-dialog>

  </div>
</template>
<script>
import { listProject, getProject, delProject, addProject, updateProject, exportProject } from "@/api/project/project";
import { listTeam, getTeam, delTeam, addTeam, updateTeam, exportTeam } from "@/api/project/team";
import {getUserTree} from "@/api/trialproduce/car";
import { treeselect } from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
  name: "Project",
  components: { Treeselect },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 项目管理表格数据
      projectList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 项目类型字典
      projectTypeOptions: [],
      // 部门树选项
      deptOptions: [],
      //用户数结构
      userTree:[],
      // 是否超时字典
      isTimeOutOptions: [],
      // 是否为里程碑节点字典
      isImportantOptions: [],
      //状态
      stateOptions: [],
      //查询时间控件
      queryProjectDateRange: [],
      //项目成员角色
      projectRoleOptions:[],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        projectName: null,
        projectCode: null,
        projectTime: null,
        projectType: null,
        startTime: null,
        isTimeOut: null,
        isImportant: null,
        deptId: null,
        userId: null,
        parentId: 0,
        beginTime: null,
        endTime: null
      },
      // 表单参数
      form: {
        projectType: null
      },
      // 表单校验
      rules: {
        projectName: [
          { required: true, message: "项目名称不能为空", trigger: "blur" }
        ],
        projectCode: [
          { required: true, message: "项目令号不能为空", trigger: "blur" }
        ],
        projectType: [
          { required: true, message: "项目类型不能为空", trigger: "blur" }
        ],
        startTime: [
          { required: true, message: "开始时间不能为空", trigger: "blur" }
        ],
        finishTime: [
          { required: true, message: "结束时间不能为空", trigger: "blur" }
        ],
        isImportant: [
          { required: true, message: "里程碑不能为空", trigger: "blur" }
        ],
        userId: [
          { required: true, message: "项目经理不能为空", trigger: "blur" }
        ],
        technologyLeaderUserId: [
          { required: true, message: "总师不能为空", trigger: "blur" }
        ],
      },
      //分解表单
      resolveForm:{

      },
      //项目组表单
      team: {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 项目组成员表格数据
        teamList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        //项目ID
        projectId: null,
        // 添加标签页
        activeName: 'first',
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          projectId: null,
          nickName: null,
          teamRole: null,

        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {
            userIds: [
              { required: true, message: "成员姓名不能为空", trigger: "blur" }
            ],
            teamRole: [
              { required: true, message: "成员角色不能为空", trigger: "blur" }
            ],
        }
      }
    };
  },
  created() {
    const path = this.$route.path;
    const projectType = path.substring(17,18);
    this.queryParams.projectType = projectType;
    this.form.projectType = projectType;
    this.getList();
    this.getTreeselect();
    this.handleUserTree();
    this.getDicts("pm_project_type").then(response => {
      this.projectTypeOptions = response.data;
    });
    this.getDicts("sys_yes_no").then(response => {
      this.isTimeOutOptions = response.data;
    });
    this.getDicts("sys_yes_no").then(response => {
      this.isImportantOptions = response.data;
    });
    this.getDicts("work_file_state").then(response => {
      this.stateOptions = response.data;
    });
    this.getDicts("pm_project_role").then(response => {
      this.projectRoleOptions = response.data;
    });
  },
  methods: {
    //用户树
    handleUserTree(){
      getUserTree().then(response => {
        this.userTree = response.data;
      });
    },
    /** 查询部门下拉树结构 */
    getTreeselect() {
      treeselect().then((response) => {
        this.deptOptions = response.data;
      });
    },
    /** 查询项目管理列表 */
    getList() {
      this.loading = true;
      listProject(this.addQueryParamsDateRange(this.queryParams)).then(response => {
        this.projectList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 项目类型字典翻译
    projectTypeFormat(row, column) {
      return this.selectDictLabel(this.projectTypeOptions, row.projectType);
    },
    // 是否超时字典翻译
    isTimeOutFormat(row, column) {
      return this.selectDictLabel(this.isTimeOutOptions, row.isTimeOut);
    },
    // 是否为里程碑节点字典翻译
    isImportantFormat(row, column) {
      return this.selectDictLabel(this.isImportantOptions, row.isImportant);
    },
    // 任务状态翻译
    stateFormat(row, column) {
      return this.selectDictLabel(this.stateOptions, row.state);
    },
    // 项目成员角色字典翻译
    isProjectRoleFormat(row, column) {
      return this.selectDictLabel(this.projectRoleOptions, row.teamRole);
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        projectId: null,
        parentId: null,
        ancestors: null,
        projectName: null,
        projectCode: null,
        projectTime: null,
        projectType: null,
        startTime: null,
        finishTime: null,
        relFinishTime: null,
        isTimeOut: null,
        isImportant: null,
        deptId: null,
        userId: null,
        createTime: null,
        updateTime: null,
        createBy: null,
        updateBy: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryProjectDateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.projectId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.form.projectType = this.queryParams.projectType;
      this.open = true;
      this.title = "添加项目管理";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const projectId = row.projectId || this.ids
      getProject(projectId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改项目管理";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.projectId != null) {
            updateProject(this.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              }
            });
          } else {
            addProject(this.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              }
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const projectIds = row.projectId || this.ids;
      this.$confirm('是否确认删除选中的数据项?删除顶级节点将会直接删除所属子节点数据。', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delProject(projectIds);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(function() {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有项目管理数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportProject(queryParams);
        }).then(response => {
          this.download(response.msg);
        }).catch(function() {});
    },
     /** 详情按钮操作 */
    handleDetails(row) {
      if(null!=row.projectId&&row.projectId!=''&row.projectId!=undefined){
          this.$router.push({
            path:'/project/tree/data/'+row.projectId,     
            query:{
              deptId:row.deptId,
              startTime: row.startTime,
              finishTime: row.finishTime,
              projectName: row.projectName
            }
          })
      }else{
         this.msgError("浏览器错误，请刷新后重试");
      }
    },
    //时间控件转换时间字段
    addQueryParamsDateRange(queryParams){
        this.queryProjectDateRange;
        this.queryParams.beginTime =  this.queryProjectDateRange[0];
        this.queryParams.endTime =  this.queryProjectDateRange[1];
        return queryParams;
    },
    //校验时间是否符合要求
    checkTime(value){
        if(null == this.form.startTime){
            this.form.finishTime = null;
            this.$message({
              showClose: true,
              message: '请选择开始时间',
              type: 'warning'
            });
        }else{
             var result = this.compareTime(this.form.startTime,value)
             if(result==false){
                this.$message({
                  showClose: true,
                  message: '结束时间不能小于开始时间',
                  type: 'warning'
                });
                this.form.finishTime = null;
             }
        }
        
    },
    //比较时间大小
    compareTime(start,end){
      let startDate = new Date(start);
      let endDate = new Date(end);
      if (endDate >= startDate) {
        return true
      } else {
        return false
      }
    },
     /** 项目组管理按钮操作 */
    handleTeam(row) {
      const projectIds = row.projectId;
      this.team.title = "项目组管理";
      this.team.open = true;
      this.team.projectId = projectIds;
      this.getTeamList();
    },
    /** 查询项目组成员列表 */
    getTeamList() {
      this.team.loading = true;
      this.team.queryParams.projectId = this.team.projectId;
      listTeam(this.team.queryParams).then(response => {
        this.team.teamList = response.rows;
        this.team.total = response.total;
        this.team.loading = false;
      });
    },
    // 项目组取消按钮
    cancelTeam() {
      this.team.open = false;
      this.resetTeam();
    },
    // 项目组表单重置
    resetTeam() {
      this.team.form = {
        teamId: null,
        projectId: null,
        userId: null,
        teamRole: null,
        createTime: null,
        updateTime: null
      };
      this.resetForm("team.form");
    },
    /** 搜索项目组按钮操作 */
    handleTeamQuery() {
      this.team.queryParams.pageNum = 1;
      this.getTeamList();
    },
    /** 重置项目组按钮操作 */
    resetTeamQuery() {
      this.resetForm("team.queryForm");
      this.handleTeamQuery();
    },
    // 多选项目组框选中数据
    handleTeamSelectionChange(selection) {
      this.team.ids = selection.map(item => item.teamId)
      this.team.single = selection.length!==1
      this.team.multiple = !selection.length
    },
    /** 新增项目组按钮操作 */
    handleTeamAdd() {
      this.reset();
      this.open = true;
      this.title = "添加项目组成员";
    },
    /** 修改项目组按钮操作 */
    handleTeamUpdate(row) {
      this.resetTeam();
      const teamId = row.teamId || this.ids
      getTeam(teamId).then(response => {
        this.team.form = response.data;
        this.team.open = true;
        this.team.title = "修改项目组成员";
      });
    },
    /** 提交项目组按钮 */
    submitTeamForm() {
      this.team.form.projectId = this.team.projectId;
      this.$refs["team.form"].validate(valid => {
        if (valid) {
          if (this.team.form.teamId != null) {
            updateTeam(this.team.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("修改成功");
                this.resetTeam();
                this.getTeamList();
              }
            });
          } else {
            addTeam(this.team.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("新增成功");
                this.resetTeam();
                this.getTeamList();
              }
            });
          }
        }
      });
    },
    /** 删除项目组按钮操作 */
    handleTeamDelete(row) {
      const teamIds = row.teamId || this.ids;
      this.$confirm('是否确认删除项目组成员编号为"' + teamIds + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delTeam(teamIds);
        }).then(() => {
          this.getTeamList();
          this.msgSuccess("删除成功");
        }).catch(function() {});
    },
    /** 导出项目组按钮操作 */
    handleTeamExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有项目组成员数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportTeam(queryParams);
        }).then(response => {
          this.download(response.msg);
        }).catch(function() {});
    },
    //修改列颜色
    tableRowClassName({row, rowIndex}) {
        if (row.isTimeOut === 'Y') {
          return 'danger-row';
        } else{
          return 'success-row';
        }
    },
  }
};
</script>
<style>
.el-table .warning-row {
  background: rgb(248, 226, 186);
}

.el-table .success-row {
  background: #ffffff;
}

.el-table .danger-row {
  background: #f51010a4;
}
</style>